package analyticsServer;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

 
/**
 * Abstract base class for all Events
 * 
 * @author Group 95
 */
public abstract class Event implements Serializable
{
    private static final SimpleDateFormat sdf=new SimpleDateFormat("dd.MM.yyyy HH:mm z");
    private static long numeric_id=0;
    
    protected String id;
    protected String type;
    protected long timestamp;
    
    public Event()
    {
    }
    
    public String getId()
    {
        return id;
    }
    
    public long getTimestamp()
    {
        return timestamp;
    }
    
    public String getType()
    {
        return this.type;
    }
    /**
     * Constructor
     * @param server (Auction or Analytic)
     * @param type
     * @param timestamp 
     */
    public Event(String server,String type,long timestamp)
    {
        synchronized(Event.class)
        {
            this.id=server+(numeric_id++);
        }
        this.type=type;
        this.timestamp=timestamp;
    }
    
    @Override
    public synchronized String toString()
    {
        return type+": "+sdf.format(new Date(timestamp)) +" - ";
    }
    
    public abstract List<StatisticsEvent> calculate(EventCalculator calculator);
}
